<template>
	<div class="x-unit" @click.self="closeMask" :style="{ height: `${deviceH}px` }">
		<div class="unit-ctx" :style="{ 'background-image': `url(${modelBg})` }">
         <div>
              <div class="ctx-title">事件详情</div>
                    <span  style="float:right" class="back" @click="closeMask">
                      <img src="../../assets/images/icon/return.png" alt />
                    </span>
              </div>

        <div style="border:1px solid #246970;width:800px;margin: 0  auto;margin-top:40px" >
          <div style="display:flex" v-if="this.detail.type=='wulian' ">
              <div class="span_left">设备名称</div>
              <div class="span_right" >{{ detail.devName }}</div>
              <div class="span_left">设备地址</div>
              <div class="span_right">{{ detail.address }}</div>
          </div>

          <div style="display:flex" v-if="this.detail.type=='shexiangtou' ">
              <div class="span_left">设备名称</div>
              <div class="span_right" >摄像头-{{ detail.id }}</div>
              <div class="span_left">地址</div>
              <div class="span_right">{{detail.address}}</div>
          </div>

           <div style="display:flex" >
              <div class="span_left1">时间</div>
              <div class="span_right1"  style="flex:1">{{ detail.nowTime }}</div>
          </div>
            <div style="display:flex" >
              <div class="span_left1">描述详情</div>
              <div class="span_right1"  style="flex:1">{{ detail.newAlarmTxt }}</div>
          </div>
           <div style="display:flex" v-if="this.detail.type=='shexiangtou' ">
              <div class="span_left1" style="height:254px">现场照片</div>
              <div class="span_right1"  style="flex:1;display:flex;height:252px;align-items:center;justify-content: space-around;">
                <div style="width:287px;height:221px; cursor: pointer;" @click="showImg(detail.alarmPic)">
                  <img :src="detail.alarmPic |filterimgsrc" alt="">
                </div>
              </div>
          </div>
          <div style="display:flex">
              <div class="span_left1">是否处理</div>
              <div class="span_right1"  style="flex:1;display:flex;">
                 <div class="header-select" style="height: 40px;width: 200px;">
                  <x-select @selectItem="selectItem2" :name="typeName2 " :listItem="typeList2" />
                </div>
              </div>
          </div>
           <div style="display:flex" v-if="typeId==2">
              <div class="span_left1">人员选择</div>
              <div class="span_right1"  style="flex:1;display:flex;">
                 <div class="header-select" style="height: 40px;width: 200px;">
                  <x-select @selectItem="selectItem1" :name="typeName " :listItem="typeList" />
                </div>
                <div class="header-select" style="height: 40px;width: 200px;margin-left:50px;">
                  <x-select @selectItem="selectItem" :name="peopleName " :listItem="peopleList" />
                </div>
              </div>
          </div>

          <div style="height:60px; display: flex;align-items: center;justify-content: center" >
            <div style=" width: 200px;background: rgb(36, 105, 112);color: rgb(255, 255, 255); height: 40px;line-height: 40px;border-radius: 4px;cursor: pointer;" @click="submit">提交</div>
          </div>


        </div>



      </div>
            <!-- dialog -->
          <el-dialog :visible.sync="dialogVisible" v-if="dialogVisible" v-dialogDrag class="jk-dialog" width="50%">
            <div style="width:786px;height:432px;margin:auto">
              <img :src="picurl |filterimgsrc" alt style="height:100%" />
            </div>
          </el-dialog>
  </div>
</template>
<script>

import {  EventAlarm} from '@/api/device'
import {
  GetSecurityInfoForPage,
} from '@/api/peopleApi'
import XSelect from '@/components/xselect'
export default{
  name:'list',
  props:{

     detail:{
      type:Object,
      default:{}
    },
    code:{
      	type: String,
    }
  },
  data(){
    return{
      list:[],
      title:'',
      modelBg: require('@/assets/images/modelBg.png'),
      deviceH:0,
      peopleList:[],
      peopleName:'',
      peoplePhone:'',
      typeName:'',
      typeList:[],
      allpeople:[],
      dialogVisible:false,
      picurl:'',
      typeName2:'处理',
      typeId:2,
      typeList2:[
        {enumName:'处理',id:2},
        {enumName:'误报警',id:4}
      ]
    }
  },
  components:{
    XSelect
  },
   beforeMount () {
    let h = document.documentElement.clientHeight || document.body.clientHeight
    this.deviceH = h
  },
  mounted() {
    this.getPeople()
    if(this.detail.type=="wulian"){
      console.log(this.detail)
    }


  },
  methods: {
    showImg(pic){
      this.dialogVisible=true;
      this.picurl=pic
    },
    closeMask(){
      this.$emit("closeMask")
    },
    selectItem2(name,id){
      this.typeName2=name
      this.typeId=id
    },
    selectItem(name,id){
      this.peopleName=name
     this.peoplePhone=id
    },
     selectItem1(name,id){
      this.typeName=name

    this.peopleList=this.allpeople.filter(item=>{
      return item.peopleType==name
     })
     console.log(this.peopleList)
      this.peopleName=this.peopleList[0].enumName
     this.peoplePhone=this.peopleList[0].id

    },
    async getPeople(){
      let pagequery = {
            code: this.code,
            pageNum: 1,
            pageSize: 100
          }

     const res = await GetSecurityInfoForPage(pagequery)
     this.allpeople=res.data.list.map(item=>{
       return {
            enumName: item.name,
            id: item.phone,
            peopleType:item.peopleType
          }
     })
    var typeList=res.data.list.map(item=>{
      return  item.peopleType
    })
    this.typeList=Array.from(new Set(typeList)).map((item,index)=>{
      return {
        enumName:item,
        id:index
      }
    })
    this.typeName=this.typeList[0].enumName
     this.peopleList=this.allpeople.filter(item=>{
      return item.peopleType==this.typeName
     })


     this.peopleName=this.peopleList[0].enumName
     this.peoplePhone=this.peopleList[0].id
    },
    async submit(){
      let params
      if(this.detail.type=="wulian"){
         params={
          alarmId:this.code+","+this.detail.nowTime+","+this.detail.deveui,
          placeId:this.code,
          alarmType:1,
          alarmDate:this.detail.nowTime,
          deviceId:this.detail.deveui,
          describe:this.detail.newAlarmTxt,
          name:this.peopleName,
          phone:this.peoplePhone,
          handleEvent:this.typeId,
          address:this.detail.address,
          deviceName:this.detail.devName,
          deviceType:this.detail.deviceType,
          alarmCode:this.detail.alarmCode
        }
      }
      if(this.detail.type=="shexiangtou"){
         params={
          alarmId:this.detail.id,
          placeId:this.code,
          alarmType:2,
          handleEvent:this.typeId,
          picUrl:this.detail.alarmPic,
          address:this.detail.address,
          alarmDate:this.detail.nowTime,
          describe:this.detail.newAlarmTxt,
          name:this.peopleName,
          phone:this.peoplePhone
        }
      }
        if(params.handleEvent==4){
          delete params.name
          delete params.phone
        }
       let res=await EventAlarm(params)
       if(res.code=="200"){
          this.closeMask()
          this.$message.success('提交成功！');
       }else{
         this.$message.error(res.msg);
       }
        // this.closeMask()
    }
  }
}
</script>
<style lang="less" scoped>
 .back {
      float: right;
      position: absolute;
      right: 60px;
      width: 0px;
      top: 30px;
      cursor: pointer;

      img {
        width: 30px;
        height: 30px;
      }
    }
	.x-unit {
		width: 100%;
		position: fixed;
		top: 0;
		left: 0;
		background: rgba(0, 0, 0, 0.8);
		z-index: 11199;
		.unit-ctx {
			position: absolute;
			top: 50%;
			transform: translateY(-50%);
			left: 0;
			right: 0;
			margin: 0 auto;
			width: 1177px;
			height: 800px;
			background-repeat: no-repeat;
			background-size: 100% 100%;
			background-position: center;
			padding: 10px 30px;
			box-sizing: border-box;
    }

  }

  body::-webkit-scrollbar {
		display: none;
	}

	.table-rs::-webkit-scrollbar {
		display: none;
  }
  .lineheader>div{
    line-height: 50px !important;
  }
  .x-unit {
  width: 100%;
  position: fixed;
  top: 0;
  left: 0;
  background: rgba(0, 0, 0, 0.8);
  z-index: 1000;
    .span_left {
    background: rgba(27, 58, 61, 0.75);
    border: 1px solid #246970;
    padding-right: 15px;
    text-align: right;
    color: #ffffff;
    width: 152px;
    height: 50px;
    line-height: 50px;
        box-sizing: border-box;
  }
   .span_left1 {
    background: rgba(27, 58, 61, 0.75);
    border: 1px solid #246970;
    padding-right: 15px;
    text-align: right;
    color: #ffffff;
    width: 152px;
    height: 52px;
    line-height: 50px;
    box-sizing: border-box;
  }
  .span_right {
    padding-left: 20px;
    text-align: left;
    color: #ffffff;
    border: 1px solid #246970;
    width: 250px;
    height: 50px;
    line-height: 50px;
        box-sizing: border-box;
  }
   .span_right1 {
    padding-left: 20px;
    text-align: left;
    color: #ffffff;
    border: 1px solid #246970;
    // width: 250px;
    height: 50px;
    line-height: 50px;
    div{
      img{
        height: 100%;
        width:100%;
      }
    }
  }
    .item-no {
                width: 50px;
                height: 100%;
                font-family: PingFangSC-Regular;
                font-size: 14px;
                color: #ffffff;
                line-height: 36px;
                text-align: center;
              }
  .item-pie {
    width: 100%;
    height: 400px;
    margin-top: 10px;
    padding: 5px 0px;
    box-sizing: border-box;
    .pie-canvas {
      width: 100%;
      height: 100%;
    }
  }
  .unit-ctx {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    left: 0;
    right: 0;
    margin: 0 auto;
    width: 1177px;
    height: 800px;
    background-repeat: no-repeat;
    background-size: 100% 100%;
    background-position: center;
    padding: 10px 30px;
    box-sizing: border-box;
    .ctx-title {
      width: 100%;
      padding-top: 10px;
      box-sizing: border-box;
      font-family: PingFangSC-Medium;
      font-size: 24px;
      color: #e9e9e9;
      letter-spacing: 4.8px;
      text-align: center;
      box-sizing: border-box;
    }
    .ctx-info {
      width: 100%;

      height: 748px;
      padding-top: 20px;
      box-sizing: border-box;
      display: flex;
      justify-content: space-around;
      align-items: flex-start;
      .info-type {
        flex: 1;
        .type-title {
          width: 100%;
          font-family: PingFangSC-Medium;
          font-size: 18px;
          color: #69d3da;
          letter-spacing: 0;
          text-align: left;
          line-height: 36px;
        }
        .type-list {
          width: 100%;
          padding: 0;
          margin-top: 26px;
          list-style: none;
          display: flex;
          flex-direction: column;
          justify-content: flex-start;
          box-sizing: border-box;
          .type-list-rs {
            width: 100%;
            list-style: none;
            margin-bottom: 20px;
            .rs-name {
              width: 100%;
              display: flex;
              justify-content: space-around;
              align-items: center;
              font-family: PingFangSC-Regular;
              font-size: 12px;
              color: #e5e5e5;
              margin-bottom: 5px;
              .name {
                flex: 1;
                text-align: left;
              }
              .number {
                flex: 1;
                text-align: right;
              }
            }
            .rs-process {
              width: 100%;
              height: 6px;
              border-radius: 4px;
              background: #333333;
              .process {
                transition: width 0.3s ease-in-out;
                height: 100%;
                border-radius: 4px;
                background-image: linear-gradient(
                  270deg,
                  #68e0cf 0%,
                  #209cff 100%
                );
              }
            }
          }
        }
      }
      .info-table {
        flex: 3;
        height: 659px;
        padding-left: 40px;
        box-sizing: border-box;
        .table-rs {
          width: 100%;
          height: 562px;
          overflow-y: auto;
          .table-header {
            width: 100%;
            height: 36px;
            display: flex;
            justify-content: space-between;
            align-items: center;
            .header-item {
              width: 186px;
              height: 100%;
              border: none;
              outline: none;
              background: #06121d;
              border: 1px solid rgba(62, 178, 215, 0);
              border-radius: 4px;
              font-size: 14px;
              color: #fff;
              padding: 0 14px;
              box-sizing: border-box;
              .input {
                font-size: 14px;
                color: #fff;
                width: 100%;
                height: 100%;
                border: none;
                outline: none;
                background: transparent;
              }
            }
            .header-select {
              width: 186px;
              margin-left: 20px;
              height: 100%;
            }
            .header-more {
              width: 56px;
              margin-left: 20px;
              font-family: PingFangSC-Regular;
              font-size: 14px;
              color: #72edf5;
              line-height: 28px;
              text-decoration: underline;
            }
            .header-btn {
              width: 66px;
              height: 100%;
              background: #72edf5;
              border-radius: 4px;
              text-align: center;
              line-height: 36px;
              font-family: PingFangSC-Regular;
              font-size: 14px;
              color: #000000;
              cursor: pointer;
            }
          }
          .table-list {
            width: 100%;
            list-style: none;
            padding: 0;
            margin-top: 15px;
            .list-item {
              padding: 0;
              margin: 0;
              list-style: none;
              width: 100%;
              display: flex;
              justify-content: space-between;
              align-items: center;
              height: 36px;

              &:nth-of-type(2n + 1) {
                background: #06121d;
              }
              &:nth-of-type(2n) {
                background: transparent;
              }
              .item-pic {
                width: 120px;
                height: 100%;
                font-family: PingFangSC-Regular;
                font-size: 14px;
                color: #ffffff;
                line-height: 36px;
                text-align: center;
              }
              .item-name {
                width: 158px;
                text-align: left;
                height: 100%;
                font-family: PingFangSC-Regular;
                font-size: 14px;
                color: #ffffff;
                line-height: 36px;
                 overflow:hidden;
              text-overflow: ellipsis;
              white-space: nowrap;
              word-break: normal;

              }
              .item-type {
                width: 116px;
                text-align: left;
                height: 100%;
                font-family: PingFangSC-Regular;
                font-size: 14px;
                color: #ffffff;
                line-height: 36px;
              }
              .item-phone {
                width: 125px;
                text-align: left;
                height: 100%;
                font-family: PingFangSC-Regular;
                font-size: 14px;
                color: #ffffff;
                line-height: 36px;
                 overflow:hidden;
              text-overflow: ellipsis;
              white-space: nowrap;
              word-break: normal;
              }
              .item-people {
                width: 116px;
                text-align: left;
                height: 100%;
                font-family: PingFangSC-Regular;
                font-size: 14px;
                color: #ffffff;
                line-height: 36px;
                 overflow:hidden;
              text-overflow: ellipsis;
              white-space: nowrap;
              word-break: normal;
              }
              .item-cardid {
                width: 194px;
                text-align: left;
                height: 100%;
                font-family: PingFangSC-Regular;
                font-size: 14px;
                color: #ffffff;
                line-height: 36px;
                 overflow:hidden;
              text-overflow: ellipsis;
              white-space: nowrap;
              word-break: normal;
              }
            }
          }
        }
        .table-footer {
          width: 100%;
          padding-top: 60px;
          box-sizing: border-box;
          display: flex;
          justify-content: flex-end;
        }
      }
    }
  }
}
</style>
